import javax.swing.*;
import javax.swing.text.rtf.RTFEditorKit;
import java.awt.*;
import java.io.FileInputStream;

/**
 * User: Ryan Green
 * Date: 2/9/11
 * Time: 4:02 PM
 * Copyright - University of South Australia
 */
public class AboutDialog extends JFrame {
	AboutDialog(LogHandler log) {

		super("About");

		try {

			this.setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE);

			// This is an empty content area in the frame
			Toolkit tk = Toolkit.getDefaultToolkit();
			Dimension screenSize = tk.getScreenSize();
			this.setLocation((screenSize.width / 2) - 350, (screenSize.height / 2) - 150);
			this.setMinimumSize(new Dimension(700, 300));

			JLabel image = new JLabel(new ImageIcon("config/mawson.png"));
			RTFEditorKit rtf = new RTFEditorKit();
			JEditorPane text = new JEditorPane();
			text.setEditable(false);
			text.setFocusable(false);
			text.setEditorKit(rtf);
			FileInputStream fi = new FileInputStream("config/about.rtf");
			rtf.read(fi, text.getDocument(), 0);
			text.setPreferredSize(new Dimension(400,100));
			text.setOpaque(false);
			text.setBorder(BorderFactory.createEmptyBorder(15,15,15,15));

			this.getContentPane().add(image, BorderLayout.EAST);
			this.getContentPane().add(text, BorderLayout.WEST);

			this.setResizable(false);
			this.setVisible(true);
		} catch (Exception e) {
			log.Log("An error occurred when displaying the about box.", true);
			log.Log(e.getStackTrace());
		}
	}
}
